package com.doctcloud.hisinfo.histable.domain.outpbill;

import com.baomidou.mybatisplus.annotation.TableName;
import com.doctcloud.common.core.annotation.Excel;
import com.doctcloud.common.core.annotation.NotZero;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.*;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Positive;
import java.io.Serializable;
import java.util.Date;

import static com.doctcloud.common.core.utils.StringUtils.trim;

/**
 * @ClassName 门诊费用记录
 * @Author samula
 * @Descripe product by com.doctcloud
 * @Data 2025-09-23 2:30
 **/
@AllArgsConstructor
@NoArgsConstructor
@Data
@EqualsAndHashCode(of={"visitDate","visitNo","itemNo"})
@ToString
public class OutpBillItemsDo implements Serializable {
    private static final long serialVersionUID = 1L;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @Excel(name = "就诊时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
    private Date visitDate;
    @Excel(name="就诊序号",cellType = Excel.ColumnType.NUMERIC)
    @Positive(message="就诊序号不能小于0")
    private Integer visitNo;
    @Excel(name="单据号")
    @NotBlank(message = "收费单据号不得为空")
    private String rcptNo;
    @Excel(name="序号")
    @Positive(message="收费序号不能为空或为零")
    private Integer itemNo;
    @Excel(name="项目分类代码")
    @NotBlank(message = "项目分类不得为空")
    private String itemClass;
    @Excel(name="项目代码")
    @NotBlank(message = "项目代码不得为空")
    private String itemCode;
    @Excel(name="项目名称")
    @NotBlank(message = "项目名称不得为空")
    private String itemName;
    @Excel(name="项目规格")
    @NotBlank(message = "项目规格不得为空")
    private String itemSpec;
    @Excel(name="数量")
    @NotZero(message = "数量不能null或零")
    private Integer amount;
    @Excel(name="计价金额")
    @NotNull
    private Double costs;
    @Excel(name="应收金额")
    @NotNull
    private Double charges;
    @Excel(name="单位")
    @NotBlank(message = "单位不能为空")
    private String units;
    @Excel(name="执行科室代码")
    private String performedBy;

    @Data
    public static class primaryKey {
        private final Date visitDate;
        private final Integer visitNo;
        private final Integer itemNo;
        public primaryKey(Date visitDate,Integer visitNo, Integer itemNo) {
            this.visitDate = visitDate;
            this.visitNo = visitNo;
            this.itemNo = itemNo;
        }
    }

    public void setItemName(String itemName) {
        this.itemName = trim(itemName);
    }
    public void setUnits(String units) {this.units = trim(units);}

    public void setRcptNo(String rcptNo) {
        this.rcptNo = trim(rcptNo);
    }

    public void setItemClass(String itemClass) {
        this.itemClass = trim(itemClass);
    }

    public void setItemCode(String itemCode) {
        this.itemCode = trim(itemCode);
    }

    public void setItemSpec(String itemSpec) {
        this.itemSpec = trim(itemSpec);
    }

    public void setPerformedBy(String performedBy) {
        this.performedBy = trim(performedBy);
    }
}
